package com.guigu.erp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.erp.mapper.DesignModuleDetailsMapper;
import com.guigu.erp.pojo.DesignModuleDetails;
import com.guigu.erp.service.DesignModuleDetailsService;
import com.guigu.erp.utils.PageUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Lenovo
 */
@Service
public class DesignModuleDetailsServiceImpl extends ServiceImpl<DesignModuleDetailsMapper, DesignModuleDetails> implements DesignModuleDetailsService{
    /**
     * 按条件分页查询物料明细表
     * @param
     * @param pageNo
     * @param pageSize
     * @return
     */
    @Override
    public PageUtils<DesignModuleDetails> moduledetailsPage(Integer id, int pageNo, int pageSize) {
        QueryWrapper wrapper=new QueryWrapper();
        //额外加1个条件
        //父级id
        System.out.println("id:"+id);
        wrapper.eq("parent_id",id);
        PageHelper.startPage(pageNo,pageSize);
        List<DesignModuleDetails> designModuleDetails=this.list(wrapper);
        PageInfo<DesignModuleDetails> pageInfo=new PageInfo<DesignModuleDetails>(designModuleDetails);

        //把PageHelper PageUtils
        PageUtils<DesignModuleDetails> pageUtils=new PageUtils<DesignModuleDetails>();
        pageUtils.setRows(pageInfo.getList());
        pageUtils.setTotal(pageInfo.getTotal());
        System.out.println(pageUtils);
        return pageUtils;
    }
}
